home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH1 / SRC / CLIP.FRM < prev    next >
Text File  |  1996-05-02  |  9KB  |  285 lines

  1. VERSION 4.00
  2. Begin VB.Form AutoForm 
  3.    Caption         =   "ClipControls"
  4.    ClientHeight    =   4365
  5.    ClientLeft      =   600
  6.    ClientTop       =   1650
  7.    ClientWidth     =   8205
  8.    Height          =   5055
  9.    Left            =   540
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4365
  12.    ScaleWidth      =   8205
  13.    Top             =   1020
  14.    Width           =   8325
  15.    Begin VB.PictureBox PaintPict 
  16.       ClipControls    =   0   'False
  17.       Height          =   4095
  18.       Index           =   2
  19.       Left            =   5520
  20.       ScaleHeight     =   269
  21.       ScaleMode       =   3  'Pixel
  22.       ScaleWidth      =   173
  23.       TabIndex        =   8
  24.       Top             =   240
  25.       Width           =   2655
  26.       Begin VB.TextBox Text1 
  27.          Alignment       =   2  'Center
  28.          BeginProperty Font 
  29.             name            =   "MS Sans Serif"
  30.             charset         =   1
  31.             weight          =   400
  32.             size            =   13.5
  33.             underline       =   0   'False
  34.             italic          =   0   'False
  35.             strikethrough   =   0   'False
  36.          EndProperty
  37.          Height          =   480
  38.          Index           =   2
  39.          Left            =   480
  40.          TabIndex        =   9
  41.          Text            =   "A text box"
  42.          Top             =   1560
  43.          Width           =   1575
  44.       End
  45.       Begin VB.Label Label2 
  46.          Alignment       =   2  'Center
  47.          BorderStyle     =   1  'Fixed Single
  48.          Caption         =   "A label"
  49.          BeginProperty Font 
  50.             name            =   "MS Sans Serif"
  51.             charset         =   1
  52.             weight          =   400
  53.             size            =   13.5
  54.             underline       =   0   'False
  55.             italic          =   0   'False
  56.             strikethrough   =   0   'False
  57.          EndProperty
  58.          Height          =   495
  59.          Index           =   2
  60.          Left            =   480
  61.          TabIndex        =   10
  62.          Top             =   600
  63.          Width           =   1575
  64.       End
  65.       Begin VB.Image Image1 
  66.          Height          =   960
  67.          Index           =   2
  68.          Left            =   720
  69.          Picture         =   "CLIP.frx":0000
  70.          Top             =   2520
  71.          Width           =   960
  72.       End
  73.    End
  74.    Begin VB.PictureBox PaintPict 
  75.       ClipControls    =   0   'False
  76.       Height          =   4095
  77.       Index           =   1
  78.       Left            =   2760
  79.       ScaleHeight     =   269
  80.       ScaleMode       =   3  'Pixel
  81.       ScaleWidth      =   173
  82.       TabIndex        =   4
  83.       Top             =   240
  84.       Width           =   2655
  85.       Begin VB.TextBox Text1 
  86.          Alignment       =   2  'Center
  87.          BeginProperty Font 
  88.             name            =   "MS Sans Serif"
  89.             charset         =   1
  90.             weight          =   400
  91.             size            =   13.5
  92.             underline       =   0   'False
  93.             italic          =   0   'False
  94.             strikethrough   =   0   'False
  95.          EndProperty
  96.          Height          =   480
  97.          Index           =   1
  98.          Left            =   480
  99.          TabIndex        =   5
  100.          Text            =   "A text box"
  101.          Top             =   1560
  102.          Width           =   1575
  103.       End
  104.       Begin VB.Label Label2 
  105.          Alignment       =   2  'Center
  106.          BorderStyle     =   1  'Fixed Single
  107.          Caption         =   "A label"
  108.          BeginProperty Font 
  109.             name            =   "MS Sans Serif"
  110.             charset         =   1
  111.             weight          =   400
  112.             size            =   13.5
  113.             underline       =   0   'False
  114.             italic          =   0   'False
  115.             strikethrough   =   0   'False
  116.          EndProperty
  117.          Height          =   495
  118.          Index           =   1
  119.          Left            =   480
  120.          TabIndex        =   6
  121.          Top             =   600
  122.          Width           =   1575
  123.       End
  124.       Begin VB.Image Image1 
  125.          Height          =   960
  126.          Index           =   1
  127.          Left            =   720
  128.          Picture         =   "CLIP.frx":0882
  129.          Top             =   2520
  130.          Width           =   960
  131.       End
  132.    End
  133.    Begin VB.PictureBox PaintPict 
  134.       Height          =   4095
  135.       Index           =   0
  136.       Left            =   0
  137.       ScaleHeight     =   269
  138.       ScaleMode       =   3  'Pixel
  139.       ScaleWidth      =   173
  140.       TabIndex        =   0
  141.       Top             =   240
  142.       Width           =   2655
  143.       Begin VB.TextBox Text1 
  144.          Alignment       =   2  'Center
  145.          BeginProperty Font 
  146.             name            =   "MS Sans Serif"
  147.             charset         =   1
  148.             weight          =   400
  149.             size            =   13.5
  150.             underline       =   0   'False
  151.             italic          =   0   'False
  152.             strikethrough   =   0   'False
  153.          EndProperty
  154.          Height          =   480
  155.          Index           =   0
  156.          Left            =   480
  157.          TabIndex        =   3
  158.          Text            =   "A text box"
  159.          Top             =   1560
  160.          Width           =   1575
  161.       End
  162.       Begin VB.Image Image1 
  163.          Height          =   960
  164.          Index           =   0
  165.          Left            =   720
  166.          Picture         =   "CLIP.frx":1104
  167.          Top             =   2520
  168.          Width           =   960
  169.       End
  170.       Begin VB.Label Label2 
  171.          Alignment       =   2  'Center
  172.          BorderStyle     =   1  'Fixed Single
  173.          Caption         =   "A label"
  174.          BeginProperty Font 
  175.             name            =   "MS Sans Serif"
  176.             charset         =   1
  177.             weight          =   400
  178.             size            =   13.5
  179.             underline       =   0   'False
  180.             italic          =   0   'False
  181.             strikethrough   =   0   'False
  182.          EndProperty
  183.          Height          =   495
  184.          Index           =   0
  185.          Left            =   480
  186.          TabIndex        =   2
  187.          Top             =   600
  188.          Width           =   1575
  189.       End
  190.    End
  191.    Begin VB.Label Label1 
  192.       Alignment       =   2  'Center
  193.       Caption         =   "ClipControls = False (manual refresh)"
  194.       Height          =   255
  195.       Index           =   2
  196.       Left            =   5520
  197.       TabIndex        =   11
  198.       Top             =   0
  199.       Width           =   2655
  200.    End
  201.    Begin VB.Label Label1 
  202.       Alignment       =   2  'Center
  203.       Caption         =   "ClipControls = False"
  204.       Height          =   255
  205.       Index           =   1
  206.       Left            =   2760
  207.       TabIndex        =   7
  208.       Top             =   0
  209.       Width           =   2655
  210.    End
  211.    Begin VB.Label Label1 
  212.       Alignment       =   2  'Center
  213.       Caption         =   "ClipControls = True"
  214.       Height          =   255
  215.       Index           =   0
  216.       Left            =   0
  217.       TabIndex        =   1
  218.       Top             =   0
  219.       Width           =   2655
  220.    End
  221.    Begin VB.Menu mnuFile 
  222.       Caption         =   "&File"
  223.       Begin VB.Menu mnuFileExit 
  224.          Caption         =   "E&xit"
  225.       End
  226.    End
  227. End
  228. Attribute VB_Name = "AutoForm"
  229. Attribute VB_Creatable = False
  230. Attribute VB_Exposed = False
  231. Option Explicit
  232.  
  233. ' ***********************************************
  234. ' Draw a grid skipping every other pixel.
  235. ' ***********************************************
  236. Sub DrawPict(pic As PictureBox)
  237. Const Amp = 3
  238. Const PI = 3.14159
  239. Const Per = 4 * PI
  240.  
  241. Dim i As Single
  242. Dim j As Single
  243. Dim hgt As Single
  244. Dim wid As Single
  245.     
  246.     pic.ScaleMode = 3   ' Pixel.
  247.     
  248.     pic.Cls     ' Clear the picture box.
  249.     
  250.     For i = 0 To pic.ScaleHeight Step 4
  251.         pic.CurrentX = 0
  252.         pic.CurrentY = i
  253.         For j = 0 To pic.ScaleWidth
  254.             pic.Line -(j, i + Amp * Sin(j / Per))
  255.         Next j
  256.     Next i
  257.     For i = 1 To hgt Step 2
  258.         pic.Line (0, i)-(wid, i)
  259.     Next i
  260. End Sub
  261.  
  262. Private Sub Form_Load()
  263.     Me.Show
  264. End Sub
  265.  
  266. Private Sub Form_Unload(Cancel As Integer)
  267.     End
  268. End Sub
  269.  
  270.  
  271. Private Sub mnuFileExit_Click()
  272.     Unload Me
  273. End Sub
  274.  
  275.  
  276.  
  277. Private Sub PaintPict_Paint(Index As Integer)
  278.     DrawPict PaintPict(Index)
  279.     
  280.     ' Manually refresh Text1(2).
  281.     If Index = 2 Then Text1(2).Refresh
  282. End Sub
  283.  
  284.  
  285.